package cn.minhx.domain.activity.service;

import cn.minhx.domain.activity.model.entity.MarketProductEntity;
import cn.minhx.domain.activity.model.entity.TrialBalanceEntity;
import cn.minhx.domain.activity.service.trial.factory.DefaultActivityStrategyFactory;
import cn.minhx.types.design.tree.StrategyHandler;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 拼团服务
 *
 * @author min
 */
@Service
public class IGroupBuyServiceImpl implements IGroupBuyService {

	@Resource
	private DefaultActivityStrategyFactory defaultActivityStrategyFactory;

	@Override
	public TrialBalanceEntity trail(MarketProductEntity marketProductEntity) throws Exception {
		StrategyHandler<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialBalanceEntity> strategyHandler = defaultActivityStrategyFactory
				.strategyHandler();
		DefaultActivityStrategyFactory.DynamicContext dynamicContext = new DefaultActivityStrategyFactory.DynamicContext();
		return strategyHandler.apply(marketProductEntity, dynamicContext);
	}
}
